package main

import (
	"gitee.com/wu-jin-feng/fgin"
	"github.com/gin-gonic/gin"
)

type myConfig struct {
	YuanBao struct {
		KeyName string `yaml:"key_name" json:"key_name"`
	} `yaml:"yuanbao" json:"yuanbao"`
	Mcp struct {
		FoodLink string `yaml:"food_link" json:"food_link"`
		MapLink  string `yaml:"map_link" json:"map_link"`
	} `yaml:"mcp" json:"mcp"`
}

func main() {
	f := fgin.Fgin{}
	r := f.GetHttpServer("./test.yaml")
	r.GET("/ping11", func(c *gin.Context) {
		cfg := f.GetConfig()
		oCfg := myConfig{}
		f.GetOtherConfig(&oCfg)
		c.JSON(200, gin.H{
			"message": oCfg,
			"other":   cfg.OtherConfig,
		})
	})
	r.GET("/ping12", func(c *gin.Context) {
		cfg, _ := fgin.ReadConfig("./test.yaml")
		oCfg := myConfig{}
		fgin.ReadOtherConfig(cfg, &oCfg)
		c.JSON(200, gin.H{
			"message": oCfg,
			"other":   cfg.OtherConfig,
			"config":  cfg,
		})
	})
	f.Run(r)
}
